package com.example.springbootmybatis.controller;

import com.example.springbootmybatis.domain.OrderInfo;
import com.example.springbootmybatis.service.OrderInfoService;
import com.example.springbootmybatis.tool.PageRequest;
import com.example.springbootmybatis.tool.PageResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @program: springboot_test
 * @description:
 * @author: Mr. Wu
 * @create: 2025-01-09 13:36
 **/

@RestController
public class OrderInfoController {

    @Autowired
    private OrderInfoService orderInfoService;

    @PostMapping("/listOrderInfoPage")
    public PageResponse<OrderInfo> listOrderInfoPage(@RequestBody PageRequest<OrderInfo> pageRequest){
        Map<String, Object> map = new HashMap<>();
        PageResponse<OrderInfo> orderInfoPageResponse =
                orderInfoService.orderInfoList(pageRequest);
        if (orderInfoPageResponse == null && orderInfoPageResponse.getResult().size() ==0) {
            map.put("code",500);
            map.put("msg","无数据");
        }else {
            map.put("code",200);
            map.put("msg","查询成功");
        }
        orderInfoPageResponse.setState(map);
        return orderInfoPageResponse;
    }

}
